﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Framework.GameStateManagment.Menue
{
    class Button
    {
        private Vector2 _position;
        private Vector2 _textPosition;
        private SpriteFont _font;
        private Texture2D _texture;
        private Texture2D _textureActiv;
        private string _text;

        public Vector2 Position
        {
            get { return _position; }
            set { _position = value; }
        }

        public Vector2 SchriftPosition
        {
            get { return _textPosition; }
            set { _textPosition = value; }
        }

        public SpriteFont Schriftart
        {
            get { return _font; }
            set { _font = value; }
        }

        public Texture2D Texture
        {
            get { return _texture; }
            set { _texture = value; }
        }

        public Texture2D TextureAktiv
        {
            get { return _textureActiv; }
            set { _textureActiv = value; }
        }

        public string Text
        {
            get { return _text; }
            set { _text = value; }
        }

        public void Draw(SpriteBatch sb)
        {
            MouseState ms = Mouse.GetState();

            if (ms.X > _position.X && ms.X < (_position.X + _texture.Width) &&
                ms.Y > _position.Y && ms.Y < (_position.Y + _texture.Height))
            {
                sb.Draw(this._textureActiv, this._position, Color.White);
            }
            else
            {
                sb.Draw(this._texture, this._position, Color.White);
            }

            sb.DrawString(this._font, this._text, this._textPosition, Color.Black);
        }

        public bool IsActive()
        {
            MouseState ms = Mouse.GetState();

            if (ms.X > _position.X && ms.X < (_position.X + _texture.Width) &&
            ms.Y > _position.Y && ms.Y < (_position.Y + _texture.Height))
            {
                return true;
            }
            return false;
        }
    }
}
